'''A simple widget for showing breadcrumbs

TODO: make the last field in the breadcrumbs editable,
so you can rename a test by editing the name in the
breadcrumb trail. 

Is that just a matter of making the widget a TextCtrl
and adding some bindings for when it gains focus?
'''
import wx

class Breadcrumbs(wx.Panel):
    '''A simple widget for showing breadcrumbs'''
    def __init__(self, *args, **kwargs):
        super(Breadcrumbs, self).__init__(*args, **kwargs)
        self.SetSizer(wx.BoxSizer(wx.HORIZONTAL))

    def SetCrumbs(self, crumbs):
        sizer = self.GetSizer()
        sizer.AddSpacer(10)
        inactive_color = wx.SystemSettings.GetColour(wx.SYS_COLOUR_GRAYTEXT)
        # WTF? On windows the caption text color is white. That sucks since the
        # breadcrumbs background is white. Until there's a reason not to
        # I'll use a hard-coded value
#        text_color = wx.SystemSettings.GetColour(wx.SYS_COLOUR_CAPTIONTEXT)
        text_color = "#b22222"
        for crumb in crumbs:
            ctrl = wx.StaticText(self, wx.ID_ANY, crumb)
            sep = wx.StaticText(self, wx.ID_ANY, ".")
            sizer.Add(ctrl, 0, wx.TOP|wx.BOTTOM|wx.ALIGN_BOTTOM, 2)
            sizer.Add(sep, 0, wx.TOP|wx.BOTTOM|wx.ALIGN_BOTTOM, 2)
            sep.SetBackgroundColour(self.GetBackgroundColour())
            ctrl.SetBackgroundColour(self.GetBackgroundColour())
            ctrl.SetForegroundColour(inactive_color)
            left_border = 0

        # make the last item stand out from the others
        font = ctrl.GetFont()
        font.SetWeight(wx.BOLD)
        ctrl.SetFont(font)
        ctrl.SetForegroundColour(text_color)

